home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / err57.doc < prev    next >
Text File  |  1983-09-02  |  3KB  |  56 lines

  1.          Device Timeout (ERR=57) on Communication Ports
  2.                         by D. Thomas Mack
  3.                          August 12, 1983
  4.  
  5. For those who write BASIC programs that read the IBM-PC's
  6. communications Ports, you will occasionally experience a DEVICE
  7. TIMEOUT error condition.  Regretably, under the BASIC interperter
  8. the system will simply "lock up" with the cursor blinking in the
  9. upper left hand corner of the screen.  If the program is
  10. compiled,  you will get a program termination (i.e. it will
  11. return to DOS) with the message on the screen DEVICE TIMEOUT. The
  12. problem occurs  when the program logic is as follows:
  13.  
  14. 1416 ON ERROR GOTO 13000 'Trap error conditions
  15. 1420 Y$=INPUT$(1,#3)     'Read the COM1 device as file # 3
  16. 1425
  17.               o
  18.               o
  19. 13000 'Error Trapping ------------------------
  20. 13009 IF ERR=57 AND ERL=1420 THEN RESUME 1425
  21.  
  22. First the DEVICE TIMEOUT condition occurs on reading a
  23. communication port in the PC for one of four types of errors:
  24.  
  25. 1.  Overrun  -- the PC did not read the data in the Receive
  26.                 Buffer Register before the next character was
  27.                 put into it,
  28. 2.  Parity   -- the parity bit is set incorrectly for the number
  29.                 of data bits received,
  30. 3.  Break    -- when a break single is detected, or
  31. 4.  Framming -- no stop bit detected following the parity bit.
  32.  
  33. The last two error conditions are handled by DOS and the BASIC
  34. interperter with no problem.  All that has to be done is to
  35. continue processing (i.e. line 13009 above is the correct logic).
  36. Error conditions 1 and 2 are the ones that present the problem
  37. because these indicators are not turned off in the Line Status
  38. Register (LSR) of the 8250 microprocessor that controls the
  39. IBM-PC's communications ports until the LSR is read (i.e. during
  40. an OPEN). If you don't want to cut somebody off by closing and
  41. opening the communications port, you can reset the error
  42. indicators in the LSR  by reading the LSR.  If you don't reset
  43. the LSR and continue processing (i.e. reading the communications
  44. port), you will either lock up your system under the BASIC
  45. interperter or return to DOS if your BASIC program has been
  46. compiled.
  47.  
  48. However, to handle the first two conditions line 13009 should be
  49. changed as follows for the IBM-PC's COM1 port:
  50.  
  51. 13009 IF ERR=57 AND ERL=1420 THEN R1=INP(&H3FD) RESUME 1425
  52.  
  53.  
  54. This error condition normally occurs under RBBS-PC when XMODEM
  55. transfers are taking place.
  56.